/**
 * interface和type的相同点
 * */

//1.都可以描述一个对象或者一个函数
//interface
interface User {
  name: string;
  age: number;
}
interface SetUser {
  (name: string, age: number): void;
}
//type
type User2 = {
  name: string;
  age: number;
};
type SetUser2 = (name: string, age: number) => void;

//2.都允许拓展
//interface
interface Name {
  name: string;
}
interface User extends Name {
  age: number;
}

type Name2 = {
  name: string;
};
type User3 = Name2 & { age: number };

type User4 = User3 & { sex: string };

interface Name {
  name: string;
}
type User5 = Name & { age: number };

type Name3 = {
  name: string;
};
interface User6 extends Name3 {
  age: number;
}

/**
 * interface和type的不同点
 * */
//1.type可以声明基本类型别名，联合类型，元组类型
type Name4 = string;

interface Dog {
  wong(): void;
}
interface Cat {
  miao(): void;
}
type Pet = Dog | Cat;

type PetList = [Dog, Cat];

//2.type语句还可以使用typeof获取实例的类型进行赋值
const div = document.createElement('div');
